package com.yth.config;

import com.yth.extension.*;
import com.yth.listener.TestApplicationReadyEventListener;
import com.yth.listener.TestContextRefreshedEventListener;
import org.springframework.beans.factory.SmartInitializingSingleton;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.beans.factory.config.DestructionAwareBeanPostProcessor;
import org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessor;
import org.springframework.beans.factory.config.SmartInstantiationAwareBeanPostProcessor;
import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor;
import org.springframework.boot.CommandLineRunner;
import org.springframework.context.ApplicationListener;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author yutianhong
 * @version 1.0
 * @since 2023/08/29 14:30:26
 */
@Configuration
public class SpringConfiguration {

    @Bean
    public static BeanDefinitionRegistryPostProcessor testBeanDefinitionRegistryPostProcessor() {
        return new TestBeanDefinitionRegistryPostProcessor();
    }

    @Bean
    public static BeanPostProcessor testBeanPostProcessor() {
        return new TestBeanPostProcessor();
    }

    @Bean
    public static InstantiationAwareBeanPostProcessor testInstantiationAwareBeanPostProcessor() {
        return new TestInstantiationAwareBeanPostProcessor();
    }

    @Bean
    public static SmartInstantiationAwareBeanPostProcessor testSmartInstantiationAwareBeanPostProcessor() {
        return new TestSmartInstantiationAwareBeanPostProcessor();
    }

    @Bean
    public static DestructionAwareBeanPostProcessor testDestructionAwareBeanPostProcessor() {
        return new TestDestructionAwareBeanPostProcessor();
    }

    @Bean
    public static SmartInitializingSingleton testSmartInitializingSingleton() {
        return new TestSmartInitializingSingleton();
    }

    @Bean
    public static CommandLineRunner myCommandLineRunner() {
        return new MyCommandLineRunner();
    }

    @Bean
    public static ApplicationListener<?> testApplicationReadyEventListener() {
        return new TestApplicationReadyEventListener();
    }

    @Bean
    public static ApplicationListener<?> testContextRefreshedEventListener() {
        return new TestContextRefreshedEventListener();
    }
}
